package com.fqgj.sentry.controller.mc;

import com.fqgj.sentry.biz.mc.BaseInfoBusiness;
import com.fqgj.sentry.common.annotations.ParamsValidate;
import com.fqgj.sentry.common.cache.RequestLocalInfo;
import com.fqgj.sentry.common.response.ApiOutput;
import com.fqgj.sentry.biz.mc.domain.ModifyBaseInfo;
import com.fqgj.sentry.biz.mc.vo.user.UserVo;
import com.fqgj.sentry.controller.mc.request.PasswordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by ykpbean kangping.ying@yuntu-inc.com
 *
 * @description
 * @create 2017-07-18 下午8:15
 */

@RestController
@RequestMapping("/base")
public class BaseInfoController {
    @Autowired
    private BaseInfoBusiness baseInfoBusiness;


    @RequestMapping(value = "/info", method = RequestMethod.POST)
    public ApiOutput getBaseInfo() {
        UserVo userVo = baseInfoBusiness.queryBaseInfo(RequestLocalInfo.getCurrentUserId());
        return new ApiOutput<>("baseinfo", userVo);
    }

    @RequestMapping(value = "/modify/info", method = RequestMethod.POST)
    public ApiOutput modifyBaseInfo(@RequestBody ModifyBaseInfo modifyBaseInfo) {
        baseInfoBusiness.modifyBaseInfo(RequestLocalInfo.getCurrentUserId(), modifyBaseInfo);
        return new ApiOutput();
    }


    @ParamsValidate
    @RequestMapping(value = "/modify/password", method = RequestMethod.POST)
    public ApiOutput modifyPassWord(@RequestBody PasswordVo passwordVo) {
        baseInfoBusiness.modifyPassWord(RequestLocalInfo.getCurrentUserId(), passwordVo.getNewPassWord(), passwordVo.getOldPassWord());
        return new ApiOutput();
    }
}
